clear all; close all; clc
a = [-0.7]; b = [0.3];
xp = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
km = 1:length(xp);
for k = km
if k > 1
h(k) = -a(1)*h(k-1) + b(1)*xh(k);
else
h(k) = b(1)*xh(k);
end
end
T = 0.001; f = 0:(1/T/100):(1/T);
z = exp(1i*2*pi*f*T);
H2 = 0;
for k = km
H2 = H2 + h(k) * z.^-k;
end
H1 = 0.3 ./ (1 - 0.7 * z.^-1);
figure(1); plot(f, abs(H1), f, abs(H2),'*')
xlabel('f, Hz'); ylabel('|H|'); 
grid('on');